<template>
	<view>
		<!-- 我发出去的,对方还没领取的 -->
		<template v-if="transferMsgInfo.content.receiveAllFlag==false&&transferMsgInfo.content.fromUserId==vuex_userInfo.id">
			<u-navbar :is-back="false" title="" :border-bottom="false">
				<view class="slot-wrap">
					<view @click="goback()">
						<u-icon name="arrow-left" :size="40" color="#000000"></u-icon>
					</view>
					<view>
						<u-icon name="more-dot-fill" :size="40" color="#000000"></u-icon>
					</view>
				</view>
			</u-navbar>
			<view class="u-p-30 u-text-center u-font-32" style="color: #000000;">
				<view class="u-p-l-20 u-p-r-20 u-p-t-80">
					<view>
						<u-icon name="clock-fill" :size="120" color="#1bb7f9"></u-icon>
					</view>
					<view class="u-m-t-50 u-font-34">
						<text>待{{transferMsgInfo.content.targetUser.friendName}}收款</text>
					</view>
					<view class="u-m-t-30" style="font-size:56rpx;font-weight: bold;">
						<text>￥</text>
						<text
							style="font-size: 64rpx;">{{Number(transferMsgInfo.content.transferAmount).toFixed(2)}}</text>
					</view>
					<view class="u-font-28 u-m-t-30 u-tips-color">
						<text>1天内对方未收款,将退还给你。</text>
						<text style="color: #00557f;font-weight: bold;">提醒对方收款</text>
					</view>
					<view class="u-m-t-60">
						<u-gap height="1" bg-color="#e7eaf1"></u-gap>
					</view>
					<view class="u-flex u-row-between u-col-center u-m-t-30 u-font-30">
						<view class="u-tips-color">
							<text>转账说明</text>
						</view>
						<view>
							<text>{{transferMsgInfo.content.transferRemark}}</text>
						</view>
					</view>
					<view class="u-flex u-row-between u-col-center u-m-t-10 u-font-30">
						<view class="u-tips-color">
							<text>转账时间</text>
						</view>
						<view>
							<text>{{transferMsgInfo.createTime}}</text>
						</view>
					</view>
				</view>
			</view>
		</template>
		<!-- 我发出去的,对方已经临走了 -->
		<template v-if="transferMsgInfo.content.receiveAllFlag==true&&transferMsgInfo.content.fromUserId==vuex_userInfo.id">
			<u-navbar :is-back="false" title="" :border-bottom="false">
				<view class="slot-wrap">
					<view @click="goback()">
						<u-icon name="arrow-left" :size="40" color="#000000"></u-icon>
					</view>
					<view>
						<u-icon name="more-dot-fill" :size="40" color="#000000"></u-icon>
					</view>
				</view>
			</u-navbar>
			<view class="u-p-30 u-text-center u-font-32" style="color: #000000;">
				<view class="u-p-l-20 u-p-r-20 u-p-t-80">
					<view>
						<u-icon name="checkmark-circle-fill" :size="120" color="#19be6b"></u-icon>
					</view>
				</view>
				<view class="u-m-t-50 u-font-34">
					<text>{{transferMsgInfo.content.targetUser.friendName}}已收款</text>
				</view>
				<view class="u-m-t-30" style="font-size:56rpx;font-weight: bold;">
					<text>￥</text>
					<text style="font-size: 64rpx;">{{Number(transferMsgInfo.content.transferAmount).toFixed(2)}}</text>
				</view>
				<view class="u-m-t-60">
					<u-gap height="1" bg-color="#e7eaf1"></u-gap>
				</view>
				<view class="u-flex u-row-between u-col-center u-m-t-30 u-font-30">
					<view class="u-tips-color">
						<text>转账时间</text>
					</view>
					<view>
						<text>{{transferMsgInfo.createTime}}</text>
					</view>
				</view>
				<view class="u-flex u-row-between u-col-center u-m-t-10 u-font-30">
					<view class="u-tips-color">
						<text>收款时间</text>
					</view>
					<view>
						<text>{{transferMsgInfo.createTime}}</text>
					</view>
				</view>
			</view>
		</template>
		<!-- 别人发给我的转账,我还没有领取 -->
		<template  v-if="transferMsgInfo.content.receiveAllFlag==false&&transferMsgInfo.content.fromUserId!=vuex_userInfo.id">
			<u-navbar :is-back="false" title="" :border-bottom="false">
				<view class="slot-wrap">
					<view @click="goback()">
						<u-icon name="arrow-left" :size="40" color="#000000"></u-icon>
					</view>
					<view>
						
					</view>
				</view>
			</u-navbar>
			<view class="u-p-30 u-text-center u-font-32" style="color: #000000;">
				<view class="u-p-l-20 u-p-r-20 u-p-t-80">
					<view>
						<u-icon name="clock" :size="120" color="#1bb7f9"></u-icon>
					</view>
					<view class="u-m-t-50 u-font-34">
						<text>待你收款</text>
					</view>
					<view class="u-m-t-60">
						<u-gap height="1" bg-color="#e7eaf1"></u-gap>
					</view>
					<view class="u-flex u-row-between u-col-center u-m-t-40 u-font-30">
						<view class="u-tips-color">
							<text>转账时间</text>
						</view>
						<view>
							<text>{{transferMsgInfo.createTime}}</text>
						</view>
					</view>
				</view>
			</view>
			<view  style="position: absolute;width: 100%;bottom: 100rpx;" class="u-flex u-row-center u-col-center">
				<view>
					<view>
						<u-button type="success" @click="receiveTransfer()">收款</u-button>
					</view>
					<view class="u-m-t-40 u-tips-color">
						<text>1天内未确认,将退还给对方。</text>
						<text  style="color: #00557f;font-weight: bold;">退还</text>
					</view>
				</view>
			</view>
		</template>
		<!-- 别人发给我的转账,我已经领取了 -->
		<template  v-if="transferMsgInfo.content.receiveAllFlag==true&&transferMsgInfo.content.fromUserId!=vuex_userInfo.id">
			<u-navbar :is-back="false" title="" :border-bottom="false">
				<view class="slot-wrap">
					<view @click="goback()">
						<u-icon name="arrow-left" :size="40" color="#000000"></u-icon>
					</view>
					<view>
						<u-icon name="more-dot-fill" :size="40" color="#000000"></u-icon>
					</view>
				</view>
			</u-navbar>
			<view class="u-p-30 u-text-center u-font-32" style="color: #000000;">
				<view class="u-p-l-20 u-p-r-20 u-p-t-80">
					<view>
						<u-icon name="checkmark-circle-fill" :size="120" color="#19be6b"></u-icon>
					</view>
				</view>
				<view class="u-m-t-50 u-font-34">
					<text>您已收款,资金已存入零钱</text>
				</view>
				<view class="u-m-t-30" style="font-size:56rpx;font-weight: bold;">
					<text>￥</text>
					<text style="font-size: 64rpx;">{{Number(transferMsgInfo.content.transferAmount).toFixed(2)}}</text>
				</view>
				<view class="u-m-t-30 u-font-30">
					<text  style="color: #00557f;font-weight: bold;">零钱余额</text>
				</view>
				<view class="u-m-t-60">
					<u-gap height="1" bg-color="#e7eaf1"></u-gap>
				</view>
				<view class="u-flex u-row-between u-col-center u-m-t-30 u-font-30">
					<view class="u-tips-color">
						<text>转账时间</text>
					</view>
					<view>
						<text>{{transferMsgInfo.createTime}}</text>
					</view>
				</view>
				<view class="u-flex u-row-between u-col-center u-m-t-10 u-font-30">
					<view class="u-tips-color">
						<text>收款时间</text>
					</view>
					<view>
						<text>{{transferMsgInfo.createTime}}</text>
					</view>
				</view>
				<view class="u-m-t-30">
					<u-gap height="1" bg-color="#e7eaf1"></u-gap>
				</view>
				<view class="u-m-t-40 u-flex u-row-between u-col-center">
					<view class="u-flex u-row-left u-col-center">
						<view class="u-flex u-row-center u-col-center" 
								style="width: 100rpx;height: 100rpx;background-color:#f8f8f8;border-radius: 50rpx;">
							<view>
								<u-icon name="integral-fill" size="60" color="#F29100"></u-icon>
							</view>
						</view>
						<view class="u-m-l-16" style="text-align: left;">
							<view class="u-font-28 u-tips-color">
								<text>零钱通 七日年化1.71%</text>
							</view>
							<view class="u-font-32 u-m-t-10" style="color: #000000;">
								<text>转入零钱通,能赚钱又能花</text>
							</view>
						</view>
					</view>
					<view>
						<u-button type="success">转入</u-button>
					</view>
				</view>
				<view class="u-m-t-40">
					<u-gap height="1" bg-color="#e7eaf1"></u-gap>
				</view>
			</view>	
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				transferMsgInfo: null
			};
		},
		onLoad(option) {
			let param = option.transferInfo;
			if (param && param.length > 0) {
				this.transferMsgInfo = JSON.parse(decodeURIComponent(param));
				console.log("转账信息", this.transferMsgInfo);
			}
		},
		methods: {
			goback() {
				uni.navigateBack();
			},
			receiveTransfer(){
				let that=this;
				this.$u.api.chatGroup.receiveTransfer(this.transferMsgInfo).then(res => {
					if(res.code==200){
						let status=res.data;
						if(status==1){
							let timestamp= new Date().getTime();
							that.transferMsgInfo.content.receiveAllFlag=true;
							that.transferMsgInfo.content.receiveMsgId=that.transferMsgInfo.id;
							that.transferMsgInfo.content.receiveTime=that.globalUtil.getTimeStr(timestamp);
							let message = {
								"id": timestamp + "",
								"chatGroupId": that.transferMsgInfo.chatGroupId,
								"userId": that.vuex_userInfo.id,
								"meFlag": true,
								"userName": that.vuex_userInfo.userName,
								"userAvatar": that.vuex_userInfo.avatar ? that.vuex_userInfo.avatar :
									"/static/image/default/default-user/default-user.png",
								'messageType': that.messageApi.MSG_TYPE.USER_MSG,
								"contentType": that.messageApi.CONTENT_TYPE.TRANSFER_CONTENT_TYPE,
								"content":that.transferMsgInfo.content,
								"createTime": that.globalUtil.getTimeStr(timestamp),
								"timestamp": timestamp,
								"platFrom": this.messageApi.msgPlat,
								"showTimeFlag": true,
							}
							console.log("发送领取转账的信息", message);
							that.globalWX.sendMessage(message, {
								complete: function(res) {
									if (res == true) {
										uni.navigateBack();
									} else {
										that.globalUtil.utilAlert("网络故障，稍后重试！");
										return;
									}
								}
							},that.messageApi.BUSINESS_CODE.chatting);
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.slot-wrap {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		/* 如果您想让slot内容占满整个导航栏的宽度 */
		flex: 1;
		/* 如果您想让slot内容与导航栏左右有空隙 */
		padding: 0 30rpx;
	}
</style>